﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks.Dataflow;

namespace BinaryComparison
{
  
    class Program
    {
        static void Main(string[] args)
        {
            var patternBytes = new byte[] { 0x01, 0x02, 0x03, 0x04 };
            FileReadBlock fileReadBlock = new FileReadBlock("input.bin", 15, patternBytes); 

            var basestream = fileReadBlock.GetFileStream();
            var basestream2 = fileReadBlock.GetFileStream2();

            long currentIndex = 0;
            long lastIndex = 0;

            foreach (var buffer in fileReadBlock.ReadBytes())
            {
                using var memoryStream = new MemoryStream(buffer);
                var fileSegmentation = new FileSegmentation(patternBytes, currentIndex,lastIndex);
                fileSegmentation.Start(memoryStream, basestream, basestream2);    
                
                currentIndex = fileSegmentation.CurrentIndex;
                lastIndex = fileSegmentation.LastIndex;
            }
            fileReadBlock.CloseFileStream();
        }
    }
}
